#ifndef __tNode_h
#define __tNode_h

#include <list>
#include "heuristicCalc.h"
#include "SmartPointer.h"

#define LIMIT2(x, y) ((x == 0 || x == (lenTab - 1)) || (y == 0 || y == (lenTab - 1)) ? 3 : 4)
#define	LIMIT(x, y) ((x == 0 || x == (lenTab - 1)) && (y == 0 || y == (lenTab - 1)) ? 2 : LIMIT2(x, y))

class	tNode
{
	int								lenTab;
	int								H;
	int								totalCout;
	int								cout;
	SmartPointer<int>				state;
	SmartPointer<tNode>				father;
	SmartPointer<heuristicCalc>		hCalc;
	std::string						key;
public:
	tNode(SmartPointer<heuristicCalc>&, SmartPointer<int>&, SmartPointer<tNode>&, const int, const int);
	tNode(tNode&);
	~tNode();

	const tNode&					operator=(tNode&);
	const bool						operator==(tNode&);
	
	const int						getH() const;
	const int						getCout() const;
	const int						getTotalCout() const;
	const int						getLenTab() const;
	SmartPointer<tNode>&			getFather();
	SmartPointer<int>&				getState();
	SmartPointer<heuristicCalc>&	getHCalc();
	std::string&					getKey();
	
	void							makeSuiteNode(std::list<SmartPointer<tNode>>&, SmartPointer<tNode>&);

	void							moveLeft(int*, const int);
	void							moveRight(int*, const int);
	void							moveUp(int*, const int);
	void							moveDown(int*, const int);

	void							setFather(const SmartPointer<tNode>&);
	void							setTotalCout(const int);
	void							setH(const int);

	void							launchCalc(int*);
	void							makeKey();
	const bool						sortNode(tNode&, tNode&);	
};

std::ostream&					operator<<(std::ostream&, tNode&);

#endif /*__Node_h*/